package com.dfbz.service.impl;

import com.dfbz.dao.UserDao;
import com.dfbz.dao.UserfocusDao;
import com.dfbz.model.User;
import com.dfbz.model.Userfocus;
import com.dfbz.service.UserDaoServlet;

import java.util.List;
import java.util.Map;

public class UserDaoServletImp implements UserDaoServlet {

    private UserDao userDao = new UserDao(User.class);
    private UserfocusDao userfocusDao = new UserfocusDao(Userfocus.class);

    @Override
    public List<User> fingPage(String realName, Integer startIndex, Integer pageSize) {
        return userDao.findPage(realName,startIndex,pageSize);

    }

    @Override
    public Integer countByRealName(String realName) {
        return userDao.countByRealName(realName);
    }

    @Override
    public List<Map<String, Object>> findAllDeptName() {
        return userDao.findAllDeptName();
    }

    public Integer findUserMessage(Long id) {
        return userDao.findUserMessage(id);
    }

    public User getById(Long id){
        return userDao.getById(id);
    }

    @Override
    public List<Map<String, Object>> getMyFocus(Integer id,Integer starPage,Integer pageNum) {
       return userDao.getMyFocus(id,starPage,pageNum);
    }

    @Override
    public Integer findAllMyFocus(Integer id) {
        return userDao.findAllMyFocus(id);
    }

    @Override
    public void cancelFocus(int userId, int foucsId) {
        userDao.cancelFocus(userId,foucsId);
    }

    @Override
    public void addFocus(Long userId, Long foucsId) {
        Userfocus userfocus = new Userfocus();
        userfocus.setUserId(userId);
        userfocus.setUserFocusId(foucsId);
        userfocusDao.save(userfocus);
    }


    public  List<Map<String, Object>> getAllMyFocus(Long id) {
        return userDao.getAllMyFocus(id);
    }

    @Override
    public Integer befocus(long messageId) {
        return userDao.befocus(messageId);
    }

    public void addLook(long messageId) {
        userDao.addLook(messageId);
    }
}
